package com.hzj.service;

import com.alibaba.fastjson.JSONObject;
import com.hzj.pojo.OrderInfo;
import com.hzj.pojo.Schedule;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class RabbitSend {
    @Autowired
    private RabbitTemplate rabbitTemplate;


    public void saveOrderInfo(OrderInfo orderInfo) {
//        System.out.println("进入rabbti保存方法"+orderInfo);
//        orderInfo.setId(1L);
        rabbitTemplate.convertAndSend("Fanout.Exchange.saveOrderInfo","", JSONObject.toJSONString(orderInfo));
    }

    public void updateOrderByHosRecordId(OrderInfo orderInfo) {
        rabbitTemplate.convertAndSend("Fanout.Exchange.updateOrderByHosRecordId",JSONObject.toJSONString(orderInfo));
    }

    public void updateScheduleById(Schedule schedule) {
        rabbitTemplate.convertAndSend("Fanout.Exchange.updateScheduleById",JSONObject.toJSONString(schedule));
    }
}
